#include "fecudp/udp_endpoint.h"
#include <iostream>

void messageCallback(const SpUdpEndpoint& endpoint, const asio::ip::udp::endpoint& remote, const char* buf, size_t len)
{
    std::string tmep(len, buf[0]);
    std::cout << "server recv: " << buf[0] << ", size = " << len << std::endl;
    assert(memcmp(&tmep[0], buf, len) == 0);
}

int main(int argc, char* argv[])
{
    asio::io_service loop;
    SpUdpEndpoint server = std::make_shared<UdpEndpoint>(loop, "0.0.0.0", 4567);
    server->setMessageCallback(messageCallback);
    //server->join_multicast_group("239.255.0.1");
    server->setDecodeBuffer(std::make_shared<MessageDecodeBuffer>(3));
    server->setEncodeBuffer(std::make_shared<MessageEncodeBuffer>(4, 1));
    server->start();

    loop.run();

    return 0;
}